Skip to content

Conversation

@hanachooi
Copy link
Collaborator

No description provided.


@RequiredArgsConstructor
@RestController
@RequestMapping("/api/colleges")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스펙상 rest api 앞에는 /api가 붙지 않습니다~


private final CollegeService collegeService;

@GetMapping("/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest api 규칙 중 마지막에 /가 붙지 않는 규칙이 있습니다.

public ResponseEntity<List<College>> findAll(){

List<College> college = collegeService.printAll();
return ResponseEntity.status(HttpStatus.CREATED).body((List<College>) college);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpStatus.CREATED 보다 HttpStatus.OK 가 더 적합한 것 같습니다~

private final TagService tagService;

@GetMapping("/")
public ResponseEntity<List<Tag>>findAll(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

커밋 전 idea의 포메팅 기능 이용을 부탁드립니다!

public ResponseEntity<List<Tag>>findAll(){

List<Tag> tag = tagService.printAll();
return ResponseEntity.status(HttpStatus.CREATED).body((List<Tag>) tag);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpStatus.CREATED 보다 HttpStatus.OK 가 더 적합한 것 같습니다~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(List)를 통해 형변환이 이루어지고 있는데,
불필요한 코드 같습니다!

}


public List<Tag> printAll(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수의 기능상 printAll()보다 findAll()이 더 적합한 것 같습니다!

private CollegeRepository collegeRepository;


public List<College> printAll(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수의 기능상 printAll()보다 findAll()이 더 적합한 것 같습니다!

@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(unique = true, insertable = false, updatable = false, length = 10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컬럼 조건을 상세하게 지정해주셨네요 👍👍


http.authorizeHttpRequests()
.anyRequest().authenticated();
.anyRequest().permitAll();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insomnia 사용하실 때만 임시로만 부탁드리겠습니다

Comment on lines +8 to +9
import java.util.List;
@RequiredArgsConstructor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl + Alt + L 단축키 사용하셔서 포매팅 부탁드립니다~

Comment on lines +16 to +18
public List<College> findAll() {
return collegeRepository.findAll();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controller <-> Service간에 데이터를 전달할 때는 entity 보다는 dto를 사용하는 것이 좋습니다~

Comment on lines +17 to +19
public List<Tag> findAll(){
return tagRepository.findAll(); }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controller <-> Service간에 데이터를 전달할 때는 entity 보다는 dto를 사용하는 것이 좋습니다~


@Getter
@Entity
@Table(name = "College")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통 데이터베이스 테이블 이름, 컬럼과 같은 곳에는 소문자만을 사용하는 것이 기본 컨벤션입니다.

Comment on lines +28 to +30
@ManyToMany
@JoinTable(schema = "College")
private List<College> users = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collages가 조금 더 적합한 네이밍일 것 같습니다~

Comment on lines +7 to +22
@Getter
public class CollegeResponse {

private final Long id;
private final String collegeName;


public CollegeResponse(College college){

this.id = college.getId();
this.collegeName = college.getName();

}


}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요즘 dto를 만들 때는 record를 사용하시면 편리합니다~

Comment on lines +6 to +19
@Getter
public class TagResponse {

private final Long id;
private final String user;


public TagResponse(Tag tag){
this.id = tag.getId();
this.user = tag.getName();
}


} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요즘 dto를 만들 때는 record를 사용하시면 편리합니다~

public ResponseEntity<List<College>> findAll(){

List<College> college = collegeService.findAll();
return ResponseEntity.status(HttpStatus.OK).body((List<College>) college);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseEntity.ok(body)를 사용하시면 조금 더 간결하고 편리하게 사용하실 수 있을 것 같습니다~


private final TagService tagService;
List<Tag> tag = tagService.findAll();
return ResponseEntity.status(HttpStatus.OK).body(tag);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseEntity.ok(body)를 사용하시면 조금 더 간결하고 편리하게 사용하실 수 있을 것 같습니다~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants